package com.letv.core.db;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import com.letv.core.constant.DatabaseConstant;
import com.letv.core.constant.LetvConstant;
import com.letv.core.constant.PlayConstant;

public class SQLiteDataBase extends SQLiteOpenHelper {

	/**
	 * 数据库版本号
	 * 
	 * 3.0 ---------------------- 30 3.1 ---------------------- 31 3.2
	 * ---------------------- 32 3.3 ---------------------- 33 3.3.0.1
	 * ------------------ 34 3.3.1 -------------------- 34 3.4
	 * ---------------------- 35 3.5 ---------------------- 36 3.5.1
	 * -------------------- 36 3.6 ---------------------- 37 3.6.1
	 * ---------------------- 38 3.7 ------------------------47 3.9
	 * ------------------------48 4.0 ------------------------49
	 * 4.1-------------------------50 5.0-------------------------51
	 * 5.1-------------------------52 5.1.2-----------------------53
	 * 5.2-------------------------53 5.1.2-----------------------54
     * 5.4.1-----------------------56 5.5.3 ----------------------57 
     * 5.6
     * 5.6-----------------------58
     * 5.7-----------------------59
     * 5.8-----------------------60
     * 6.0-----------------------63
	 */
	public static final int DATABASE_VERSION = 63;

	/**
	 * 数据库名称
	 */
	public static final String DATABASE_NAME = "dbletv.db";

	public SQLiteDataBase(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		Log.d("HYX", "COME  INTO onCreate!!");
		/**
		 * 创建搜索表
		 * */
		createTable_searchTrace(db);
		/**
		 * 创建收藏表
		 * */
		createTable_favoriteTrace(db);
		/**
		 * 创建播放记录表
		 * */
		createTable_playTrace(db);
		/**
		 * 创建宫格已观看播放记录表
		 * */
		createTable_playTraceWatched(db);
		/**
		 * 创建下载表
		 * */
		createTable_downloadTrace(db);
		/**
		 * 创建开机引导图
		 * */
		createTable_festivalImageTrace(db);

		/**
		 * 本地视频数据库
		 * */
		createTable_localVideoTrace(db);

		/**
		 * 直播预定数据库
		 * */
		createTable_liveBookTrace(db);
		/**
		 * 客户端提示语服务端化数据库
		 */
		createTable_DialogMsgTrace(db);
		/**
		 * 客户端多页面显示缓存 数据库
		 */
		createTable_LocalCacheTrace(db);

		/**
		 * 顶级频道序列
		 * */
		createTable_TopChannelsTrace(db);
		/**
		 * 频道收藏
		 */
		createTable_channelListSaveTrace(db);
		/**
		 * 频道历史 /缓存数据
		 */
		createTable_channelHisListTrace(db);
        /**
         * 世界杯口袋看球功能（v5.4.1）
         */
        createTable_worldCupTrace(db);
        
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.d("ljnalex", "-----onUpgrade-----oldVersion:" + oldVersion + "; newVersion:" + newVersion);
        Log.d("HYX", "-----onUpgrade-----oldVersion:" + oldVersion + "; newVersion:" + newVersion);
       
        if (oldVersion <= 59){
        	Log.d("", "download add new DURATION");
    	   /**
            * 向下载列表中增加一个属性字段，用户时长
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.DURATION + " INTEGER DEFAULT 1;");
           
           /**
			 * 创建宫格已观看播放记录表
			 * */
           createTable_playTraceWatched(db);
       }
       if(oldVersion==58){
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");
           
			/**
			 * 创建宫格已观看播放记录表
			 * */
			createTable_playTraceWatched(db);
       }else if(oldVersion==57){
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");
         /**
         * 向收藏列表中增加“频道状态”\"频道类型"属性字段
         */
		  // db.execSQL("ALTER TABLE " + DatabaseConstant.ChannelListTrace.TABLE_NAME + " ADD COLUMN "
				//   + DatabaseConstant.ChannelListTrace.Field.CHANNELSTATUS + " TEXT DEFAULT " + DatabaseConstant.ChannelListTrace.ChannelStatus.NORMAL+";");
        /**
         * 向频道历史列表中增加“频道状态”、"频道类型"属性字段
         */
		 //  db.execSQL("ALTER TABLE " + DatabaseConstant.ChannelHisListTrace.TABLE_NAME + " ADD COLUMN "
				//   + DatabaseConstant.ChannelHisListTrace.Field.CHANNEL_TYPE + " TEXT DEFAULT " + DatabaseConstant.ChannelHisListTrace.ChannelType.TYPE_LUNBO+"," 
				   //+ DatabaseConstant.ChannelHisListTrace.Field.CHANNELSTATUS + " TEXT DEFAULT " + DatabaseConstant.ChannelHisListTrace.ChannelStatus.NORMAL + ";");
        
        /**
		 * 创建宫格已观看播放记录表
		 * */
		createTable_playTraceWatched(db);
       }else if(oldVersion == 56){
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");

           /**
            * 向下载列表中增加一个属性字段，用户是否观看
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");
           /**
   		 	* 频道收藏
   		 	*/
   			createTable_channelListSaveTrace(db);
   			/**
   			 * 频道历史
   			 */
   			createTable_channelHisListTrace(db);
   			/**
			 * 创建宫格已观看播放记录表
			 * */
			createTable_playTraceWatched(db);
	   }else if(oldVersion == 55) {
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");

           /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
            db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");
            /**
    		 * 频道收藏
    		 */
    		createTable_channelListSaveTrace(db);
    		/**
    		 * 频道历史
    		 */
    		createTable_channelHisListTrace(db);
    		
    		/**
			 * 创建宫格已观看播放记录表
			 * */
			createTable_playTraceWatched(db);
        } else if (oldVersion == 54) {
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");

           /**
			 *  5.3.1新增一个资讯频道 顶级频道序列
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
            db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");
            /**
    		 * 频道收藏
    		 */
    		createTable_channelListSaveTrace(db);
    		/**
    		 * 频道历史
    		 */
    		createTable_channelHisListTrace(db);
    		
    		/**
			 * 创建宫格已观看播放记录表
			 * */
			createTable_playTraceWatched(db);
		} else if (oldVersion == 53) {
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");

           /**
			 *  5.2新增三个频道 顶级频道序列
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
		   db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");
            
            /**
    		 * 频道收藏
    		 */
    		createTable_channelListSaveTrace(db);
    		/**
    		 * 频道历史
    		 */
    		createTable_channelHisListTrace(db);
    		
    		/**
			 * 创建宫格已观看播放记录表
			 * */
			createTable_playTraceWatched(db);
		} else if (oldVersion == 52) {
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");

           /**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
            db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");
            /**
    		 * 频道收藏
    		 */
    		createTable_channelListSaveTrace(db);
    		/**
    		 * 频道历史
    		 */
    		createTable_channelHisListTrace(db);
    		
    		/**
			 * 创建宫格已观看播放记录表
			 * */
			createTable_playTraceWatched(db);
		} else if (oldVersion == 51) {
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");

			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 5.1播放记录添加IMG300
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.PlayRecord.Field.IMG300 + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
		   db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");
            /**
    		 * 频道收藏
    		 */
    		createTable_channelListSaveTrace(db);
    		/**
    		 * 频道历史
    		 */
    		createTable_channelHisListTrace(db);
    		
    		/**
			 * 创建宫格已观看播放记录表
			 * */
			createTable_playTraceWatched(db);
		} else if (oldVersion == 50) {
           /**
            * 向播放记录表里增加一个VIDEOTYPEKEY属性字段
            */
           db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
                   + DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT ;");

			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 5.1播放记录添加IMG300
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.PlayRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.PlayRecord.Field.IMG300 + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.0 缓存添加ASSISTKEY
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LocalCacheTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LocalCacheTrace.Field.ASSISTKEY + " TEXT;");
			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 收藏增加副标题、是否完结、总集数
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.SUBTITLE + " TEXT;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.ISEND + " INTEGER;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.EPISODE + " INTEGER;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
            db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");

		} else if (oldVersion == 49) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1 播放数据库更改逻辑，需要清除老表
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_playTrace(db);
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 5.0 收藏增加副标题、是否完结、总集数
			 */

			db.execSQL("drop table if exists " + DatabaseConstant.FavoriteRecord.TABLE_NAME);
			createTable_favoriteTrace(db);

			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
            db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");

		} else if (oldVersion == 48) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 5.0 收藏增加副标题、是否完结、总集数
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.SUBTITLE + " TEXT;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.ISEND + " INTEGER;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.EPISODE + " INTEGER;");
			/**
			 * 4.1 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);
			/**
			 * 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);

			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
            db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");

		} else if (oldVersion == 47) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 5.0 收藏增加副标题、是否完结、总集数
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.SUBTITLE + " TEXT;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.ISEND + " INTEGER;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.EPISODE + " INTEGER;");
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);
			/**
			 * 3.8 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
		   db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");

		} else if (oldVersion == 38) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 5.0 收藏增加副标题、是否完结、总集数
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.SUBTITLE + " TEXT;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.ISEND + " INTEGER;");
		   db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.FavoriteRecord.Field.EPISODE + " INTEGER;");
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
		   db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
		   db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);
			/**
			 * 3.8 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);
			/**
			 * 3.7 添加下载路径
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT;");
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");

            /**
             * 世界杯口袋看球功能（v5.4.1）
             */
            createTable_worldCupTrace(db);
            /**
             * 向下载列表中增加一个属性字段，用户是否观看
             */
            db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 1;");

		} else if (oldVersion == 37) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
		   db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
		   db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 5.0 收藏增加副标题、是否完结、总集数
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.SUBTITLE + " TEXT;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.ISEND + " INTEGER;");
		   db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.FavoriteRecord.Field.EPISODE + " INTEGER;");
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
		   db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);
			/**
			 * 3.8 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);

			/**
			 * 3.7 添加下载路径
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT;");
			/**
			 * 3.6.1 收藏夹表添加 ISDOLBY 字段
			 * */
		   db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.FavoriteRecord.Field.ISDOLBY + " INTEGER;");
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");
		} else if (oldVersion == 36) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 5.0 收藏增加副标题、是否完结、总集数
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.SUBTITLE + " TEXT;");
		   db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.FavoriteRecord.Field.ISEND + " INTEGER;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.EPISODE + " INTEGER;");
			/**
			 * 5.0 开机大图表删除
			 * */
		   db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);

			/**
			 * 3.6 添加直播预定数据库
			 * */
			createTable_liveBookTrace(db);

			/**
			 * 3.8 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);

			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
		   db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 3.7 添加下载路径
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT;");
			/**
			 * 3.6.1 收藏夹表添加 ISDOLBY 字段
			 * */
			db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.FavoriteRecord.Field.ISDOLBY + " INTEGER;");

			/**
			 * 3.6 收藏夹表添加 AID 字段
			 * */
		   db.execSQL("ALTER TABLE " + DatabaseConstant.FavoriteRecord.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.FavoriteRecord.Field.AID + " INTEGER;");
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");
		} else if (oldVersion == 35) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);

			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 3.7 添加下载路径
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT;");

			/**
			 * 3.5 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);

			/**
			 * 3.5 收藏数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FavoriteRecord.TABLE_NAME);
			createTable_favoriteTrace(db);

			/**
			 * 3.6 添加直播预定数据库
			 * */
			createTable_liveBookTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");
		} else if (oldVersion == 34) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);

			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 3.7 添加下载路径
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT;");
			/**
			 * 3.4新加本地视频表
			 * */
			createTable_localVideoTrace(db);

			/**
			 * 3.5 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);
			/**
			 * 3.5 收藏数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FavoriteRecord.TABLE_NAME);
			createTable_favoriteTrace(db);

			/**
			 * 3.6 添加直播预定数据库
			 * */
			createTable_liveBookTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");
		} else if (oldVersion == 33) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);

			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 3.7 添加下载路径
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT;");
			try {
				/**
				 * 更新下载记录表，为处理3.3发版后出现的数据库更新错误，需要重新更新数据库，可能会异常，处理掉
				 * */
				db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
						+ DatabaseConstant.DownloadTrace.Field.CID + " INTEGER;");
			} catch (Exception e) {
			}
			/**
			 * 3.4新加本地视频表
			 * */
			createTable_localVideoTrace(db);

			/**
			 * 3.5 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);
			/**
			 * 3.5 收藏数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FavoriteRecord.TABLE_NAME);
			createTable_favoriteTrace(db);

			/**
			 * 3.6 添加直播预定数据库
			 * */
			createTable_liveBookTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");
		} else if (oldVersion == 32) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);

			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
		   db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
		   db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
				   + DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 5.0 开机大图表删除
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 3.7 添加下载路径
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT;");
			try {
				/**
				 * 更新下载记录表，下载表在3.3加入下载统计，加入cid字段
				 * */
				db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
						+ DatabaseConstant.DownloadTrace.Field.CID + " INTEGER;");
			} catch (Exception e) {
			}

			/**
			 * 3.4新加本地视频表
			 * */
			createTable_localVideoTrace(db);

			/**
			 * 3.5 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);
			/**
			 * 3.5 收藏数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FavoriteRecord.TABLE_NAME);
			createTable_favoriteTrace(db);

			/**
			 * 3.6 添加直播预定数据库
			 * */
			createTable_liveBookTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");
		} else if (oldVersion == 31) {
			/**
			 * 5.1.2下载添加剧集ICON
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT;");
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);
			/**
			 * 5.0 下载增加区分新旧数据库字段、片头、片尾时间
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0;");
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0;");
			/**
			 * 4.1添加下载影片类型
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER;");
			/**
			 * 3.7 添加下载路径
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT;");
			/**
			 * 更新下载记录表
			 * */
			db.execSQL("ALTER TABLE " + DatabaseConstant.DownloadTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.DownloadTrace.Field.CID + " INTEGER;");

			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);
			/**
			 * 3.4新加本地视频表
			 * */
			createTable_localVideoTrace(db);

			/**
			 * 3.5 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);
			/**
			 * 3.5 收藏数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FavoriteRecord.TABLE_NAME);
			createTable_favoriteTrace(db);

			/**
			 * 3.6 添加直播预定数据库
			 * */
			createTable_liveBookTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");
		} else if (oldVersion == 30) {
			/**
			 * 顶级频道序列 5.1添加
			 * */
			try {
				db.execSQL("drop table if exists " + DatabaseConstant.TopChannelsTrace.TABLE_NAME);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			createTable_TopChannelsTrace(db);
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.LocalCacheTrace.TABLE_NAME);
			createTable_LocalCacheTrace(db);
			/**
			 * 4.0 客户端提示语服务端化数据库
			 */
			db.execSQL("drop table if exists " + DatabaseConstant.DialogMsgTrace.TABLE_NAME);
			createTable_DialogMsgTrace(db);

			db.execSQL("drop table if exists " + DatabaseConstant.FestivalImageTrace.TABLE_NAME);
			createTable_festivalImageTrace(db);

			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);

			db.execSQL("drop table if exists " + DatabaseConstant.DownloadTrace.TABLE_NAME);
			createTable_downloadTrace(db);

			/**
			 * 3.4新加本地视频表
			 * */
			createTable_localVideoTrace(db);

			/**
			 * 3.5 播放数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.PlayRecord.TABLE_NAME);
			createTable_playTrace(db);
			/**
			 * 3.5 收藏数据库更改逻辑，需要清除老表
			 * */
			db.execSQL("drop table if exists " + DatabaseConstant.FavoriteRecord.TABLE_NAME);
			createTable_favoriteTrace(db);

			/**
			 * 3.6 添加直播预定数据库
			 * */
			createTable_liveBookTrace(db);
			/**
			 * 5.1区分预约类型：轮播台，卫视台，直播厅
			 */
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER DEFAULT "
					+ PlayConstant.LiveType.PLAY_LIVE_WEISHI + ";");
		} else {
			createTable_searchTrace(db);
			createTable_favoriteTrace(db);
			createTable_playTrace(db);
			createTable_downloadTrace(db);
			createTable_festivalImageTrace(db);
			createTable_localVideoTrace(db);

			/**
			 * 3.6 添加直播预定数据库
			 * */
			createTable_liveBookTrace(db);
			createTable_DialogMsgTrace(db);
			/**
			 * 4.1 客户端多页面显示缓存 数据库
			 */
			createTable_LocalCacheTrace(db);
			
			/**
			 * 顶级频道序列 5.1添加
			 * */
			createTable_TopChannelsTrace(db);
		}
		//add by zlb
		if(oldVersion < 60 && oldVersion > 56) {//修改旧版本创建的数据库，增加新字段，删除无用字段
//			db.beginTransaction();
			try {
				alterChannelListTable(db);
				db.execSQL("ALTER TABLE " + DatabaseConstant.ChannelListTrace.TABLE_NAME + " ADD COLUMN "
						+ DatabaseConstant.ChannelListTrace.Field.CHANNEL_TYPE+ " TEXT DEFAULT " + DatabaseConstant.ChannelHisListTrace.ChannelType.TYPE_LUNBO+";" );
				db.execSQL("ALTER TABLE " + DatabaseConstant.ChannelListTrace.TABLE_NAME + " ADD COLUMN "
						+ DatabaseConstant.ChannelListTrace.Field.CHANNELSTATUS + " TEXT DEFAULT " + DatabaseConstant.ChannelListTrace.ChannelStatus.NORMAL+";");
//				db.setTransactionSuccessful();
				Log.d("database_", "setTransactionSuccessful 1------------------- alterChannelListTable");
			} catch (Exception e) {
			    Log.d("database_", "Exception ------------------- alterChannelListTable");
			} finally {
//				db.endTransaction();
			}
//			db.beginTransaction();
			try {
				alterChannelHisTable(db);
				db.execSQL("ALTER TABLE " + DatabaseConstant.ChannelHisListTrace.TABLE_NAME + " ADD COLUMN "
						 + DatabaseConstant.ChannelHisListTrace.Field.CHANNEL_TYPE + " TEXT DEFAULT " + DatabaseConstant.ChannelHisListTrace.ChannelType.TYPE_LUNBO+";" );
				db.execSQL("ALTER TABLE " + DatabaseConstant.ChannelHisListTrace.TABLE_NAME + " ADD COLUMN "
						+ DatabaseConstant.ChannelHisListTrace.Field.CHANNELSTATUS  + " TEXT DEFAULT " + DatabaseConstant.ChannelHisListTrace.ChannelStatus.NORMAL+";");
//				db.setTransactionSuccessful();
				Log.d("database_", "setTransactionSuccessful 2------------------- alterChannelHisTable");
			} catch (Exception e) {
				e.printStackTrace();
				Log.d("database_", "Exception ------------------- ChannelHisListTrace");
			} finally {
//				db.endTransaction();
			}
		}

		if(oldVersion < 60) {
			db.execSQL("ALTER TABLE " + DatabaseConstant.LiveBookTrace.TABLE_NAME + " ADD COLUMN "
					+ DatabaseConstant.LiveBookTrace.Field.LIVE_ID + " TEXT;");
		}
		//end by zlb
	}

	private void createTable_festivalImageTrace(SQLiteDatabase db) {

		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.FestivalImageTrace.TABLE_NAME + "("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT," + DatabaseConstant.FestivalImageTrace.Field.NAME
				+ " TEXT," + DatabaseConstant.FestivalImageTrace.Field.PIC + " TEXT,"
				+ DatabaseConstant.FestivalImageTrace.Field.START_TIME + " TEXT,"
				+ DatabaseConstant.FestivalImageTrace.Field.END_TIME + " TEXT,"
				+ DatabaseConstant.FestivalImageTrace.Field.ORDER + " INTEGER " + ");");

	}
	
	private void createTable_channelListSaveTrace(SQLiteDatabase db){
		String sql="CREATE TABLE "+DatabaseConstant.ChannelListTrace.TABLE_NAME+"("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT,"+DatabaseConstant.ChannelListTrace.Field.CHANNELID
				+" TEXT,"+DatabaseConstant.ChannelListTrace.Field.NUMERICKEYS+" TEXT,"
				+DatabaseConstant.ChannelListTrace.Field.NAME+" TEXT,"
				+DatabaseConstant.ChannelListTrace.Field.ENAME+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.BEGINTIME+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.ENDTIME+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.CHANNELCLASS+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.BELONGBRAND+" INTEGER,"
//				+ DatabaseConstant.ChannelListTrace.Field.SOURCEID+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.IS3D+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.IS4K+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.CH+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.ORDERNO+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.ISCOMMEND+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.LOGO120X90+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.LOGOORIGIN+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.LOGO150X200+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.LOGO120X160+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.LOGO96X128+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.LOGO150X150+" TEXT,"
//				+ DatabaseConstant.ChannelListTrace.Field.LOGO30X30+" TEXT,"
				+ DatabaseConstant.ChannelListTrace.Field.CHANNEL_TYPE+" TEXT,"
				+ DatabaseConstant.ChannelListTrace.Field.HASSAVE+" INTEGER,"
				+ DatabaseConstant.ChannelListTrace.Field.CHANNELSTATUS+" TEXT DEFAULT "+DatabaseConstant.ChannelListTrace.ChannelStatus.NORMAL+");";
		System.out.println(sql);
		db.execSQL(sql);			
	}
	
	private void createTable_channelHisListTrace(SQLiteDatabase db){
		String sql="CREATE TABLE "+DatabaseConstant.ChannelHisListTrace.TABLE_NAME+"("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT,"+DatabaseConstant.ChannelHisListTrace.Field.CHANNELID
				+" TEXT,"+DatabaseConstant.ChannelHisListTrace.Field.NUMERICKEYS+" TEXT,"
				+DatabaseConstant.ChannelHisListTrace.Field.NAME+" TEXT,"
				+DatabaseConstant.ChannelHisListTrace.Field.ENAME+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.BEGINTIME+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.ENDTIME+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.CHANNELCLASS+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.BELONGBRAND+" INTEGER,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.SOURCEID+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.IS3D+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.IS4K+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.CH+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.ORDERNO+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.ISCOMMEND+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.LOGO120X90+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.LOGOORIGIN+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.LOGO150X200+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.LOGO120X160+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.LOGO96X128+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.LOGO150X150+" TEXT,"
//				+ DatabaseConstant.ChannelHisListTrace.Field.LOGO30X30+" TEXT,"
				+ DatabaseConstant.ChannelListTrace.Field.CHANNEL_TYPE+" TEXT,"
				+ DatabaseConstant.ChannelHisListTrace.Field.ISRECORD+" INTEGER,"
				+ DatabaseConstant.ChannelHisListTrace.Field.SYSTEMILLISECOND+" INTEGER,"
				+ DatabaseConstant.ChannelHisListTrace.Field.CHANNELSTATUS+" TEXT DEFAULT "+DatabaseConstant.ChannelHisListTrace.ChannelStatus.NORMAL+");";
		db.execSQL(sql);			
	}
	
	
	
	private void createTable_searchTrace(SQLiteDatabase db) {

		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.SearchTrace.TABLE_NAME + "("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT," + DatabaseConstant.SearchTrace.Field.NAME + " TEXT,"
				+ DatabaseConstant.SearchTrace.Field.TIMESTAMP + " INTEGER " + ");");
	}

	private void createTable_playTrace(SQLiteDatabase db) {

		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.PlayRecord.TABLE_NAME + "("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT," + DatabaseConstant.PlayRecord.Field.CID + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.IMG300 + " TEXT," + DatabaseConstant.PlayRecord.Field.PID
				+ " INTEGER," + DatabaseConstant.PlayRecord.Field.VID + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.NVID + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.UID + " TEXT," + DatabaseConstant.PlayRecord.Field.VTYPE
				+ " INTEGER," + DatabaseConstant.PlayRecord.Field.FROM + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.VTIME + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.HTIME + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.UTIME + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.STATE + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.TYPE + " INTEGER,"
				+ DatabaseConstant.PlayRecord.Field.VIDEOTYPEKEY + " TEXT,"
				+ DatabaseConstant.PlayRecord.Field.TITLE + " TEXT," + DatabaseConstant.PlayRecord.Field.IMG
				+ " TEXT," + DatabaseConstant.PlayRecord.Field.NC + " TEXT " + ");");
	}
	
	private void createTable_playTraceWatched(SQLiteDatabase db) {

		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.PlayRecordWatched.TABLE_NAME + "("
				+ DatabaseConstant.PlayRecordWatched.Field.VID + " INTEGER PRIMARY KEY,"
				+ DatabaseConstant.PlayRecordWatched.Field.PID + " INTEGER);");
	}

	private void createTable_favoriteTrace(SQLiteDatabase db) {

		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.FavoriteRecord.TABLE_NAME + "("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT," + DatabaseConstant.FavoriteRecord.Field.TIMESTAMP
				+ " INTEGER," + DatabaseConstant.FavoriteRecord.Field.ID + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.AID + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.TITLE + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.ICON + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.SCORE + " REAL,"
				+ DatabaseConstant.FavoriteRecord.Field.CID + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.YEAR + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.COUNT + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.TIMELENGTH + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.DIRECTOR + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.ACTOR + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.AREA + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.SUBCATE + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.RCOMPANY + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.TYPE + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.AT + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.ALBUMTYPE + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.SINGLEPRICE + " REAL,"
				+ DatabaseConstant.FavoriteRecord.Field.ALLOWMONTH + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.PAYDATE + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.NEEDJUMP + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.PAY + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.ISDOLBY + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.SUBTITLE + " TEXT,"
				+ DatabaseConstant.FavoriteRecord.Field.ISEND + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.EPISODE + " INTEGER,"
				+ DatabaseConstant.FavoriteRecord.Field.CTIME + " TEXT " + ");");
	}

	private void createTable_downloadTrace(SQLiteDatabase db) {

		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.DownloadTrace.TABLE_NAME + "("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT," + DatabaseConstant.DownloadTrace.Field.EPISODE_ID
				+ " INTEGER," + DatabaseConstant.DownloadTrace.Field.ALBUM_ID + " INTEGER,"
				+ DatabaseConstant.DownloadTrace.Field.CID + " INTEGER,"
				+ DatabaseConstant.DownloadTrace.Field.ICON + " TEXT,"
				+ DatabaseConstant.DownloadTrace.Field.EPISODE_ICON + " TEXT,"
				+ DatabaseConstant.DownloadTrace.Field.TYPE + " INTEGER,"
				+ DatabaseConstant.DownloadTrace.Field.ORDER + " INTEGER,"
				+ DatabaseConstant.DownloadTrace.Field.EPISODE_TITLE + " TEXT,"
				+ DatabaseConstant.DownloadTrace.Field.ALBUM_TITLE + " TEXT,"
				+ DatabaseConstant.DownloadTrace.Field.TOTAL_SIZE + " INTEGER,"
				+ DatabaseConstant.DownloadTrace.Field.FINISH + " INTEGER, "
				+ DatabaseConstant.DownloadTrace.Field.TIMESTAMP + " INTEGER,"
				+ DatabaseConstant.DownloadTrace.Field.LENGTH + " INTEGER, "
				+ DatabaseConstant.DownloadTrace.Field.FILE_PATH + " TEXT,"
				+ DatabaseConstant.DownloadTrace.Field.ISHD + " INTEGER,"
				+ DatabaseConstant.DownloadTrace.Field.IS_NEW + " INTEGER DEFAULT 0,"
				+ DatabaseConstant.DownloadTrace.Field.B_TIME + " INTEGER DEFAULT 0,"
		        + DatabaseConstant.DownloadTrace.Field.E_TIME + " INTEGER DEFAULT 0, "
		        + DatabaseConstant.DownloadTrace.Field.DURATION + " INTEGER DEFAULT 0, "
		        + DatabaseConstant.DownloadTrace.Field.IS_WATCH + " INTEGER DEFAULT 0" + ");");
	}

	/**
	 * 本地视频
	 * 
	 * @author liuheyuan
	 * @param db
	 */
	private void createTable_localVideoTrace(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.LocalVideoTrace.TABLE_NAME + "("
				+ DatabaseConstant.LocalVideoTrace.Field.PATH + " TEXT PRIMARY KEY,"
				+ DatabaseConstant.LocalVideoTrace.Field.TITLE + " TEXT,"
				+ DatabaseConstant.LocalVideoTrace.Field.POSITION + " TEXT DEFAULT \"" + LetvConstant.PLAY_FINISH
				+ "\"," + DatabaseConstant.LocalVideoTrace.Field.FILESIZE + " TEXT,"
				+ DatabaseConstant.LocalVideoTrace.Field.TIMELENGTH + " TEXT,"
				+ DatabaseConstant.LocalVideoTrace.Field.VIDEO_W_H + " TEXT,"
				+ DatabaseConstant.LocalVideoTrace.Field.VIDEO_TYPE + " TEXT,"
				+ DatabaseConstant.LocalVideoTrace.Field.CREATETIME + " TEXT" + ");");
	}

	/**
	 * 直播预定
	 */
	private void createTable_liveBookTrace(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.LiveBookTrace.TABLE_NAME + "("
				+ DatabaseConstant.LiveBookTrace.Field.MD5_ID + " TEXT PRIMARY KEY,"
				+ DatabaseConstant.LiveBookTrace.Field.PROGRAMNAME + " TEXT,"
				+ DatabaseConstant.LiveBookTrace.Field.CHANNELNAME + " TEXT,"
				+ DatabaseConstant.LiveBookTrace.Field.CODE + " TEXT,"
				+ DatabaseConstant.LiveBookTrace.Field.LAUNCH_MODE + " INTEGER,"
				+ DatabaseConstant.LiveBookTrace.Field.PLAY_TIME_LONG + " INTEGER,"
				+ DatabaseConstant.LiveBookTrace.Field.IS_NOTIFY + " INTEGER,"
				+ DatabaseConstant.LiveBookTrace.Field.LIVE_ID + " TEXT,"
				+ DatabaseConstant.LiveBookTrace.Field.PLAY_TIME + " TEXT" + ");");
	}

	/**
	 * 客户端提示语服务端化
	 */
	private void createTable_DialogMsgTrace(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.DialogMsgTrace.TABLE_NAME + "("
				+ DatabaseConstant.DialogMsgTrace.Field.MSGID + " TEXT PRIMARY KEY,"
				+ DatabaseConstant.DialogMsgTrace.Field.MAGTITLE + " TEXT,"
				+ DatabaseConstant.DialogMsgTrace.Field.MESSAGE + " TEXT" + ");");
	}

	/**
	 * 客户端多页面显示本地缓存
	 */
	private void createTable_LocalCacheTrace(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.LocalCacheTrace.TABLE_NAME + "("
				+ DatabaseConstant.LocalCacheTrace.Field.CACHEID + " TEXT PRIMARY KEY,"
				+ DatabaseConstant.LocalCacheTrace.Field.ASSISTKEY + " TEXT,"
				+ DatabaseConstant.LocalCacheTrace.Field.MARKID + " TEXT,"
				+ DatabaseConstant.LocalCacheTrace.Field.CACHETIME + " TEXT,"
				+ DatabaseConstant.LocalCacheTrace.Field.CACHEDATA + " TEXT" + ");");
	}

	/**
	 * 顶级页面频道序列
	 */
	private void createTable_TopChannelsTrace(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS " + DatabaseConstant.TopChannelsTrace.TABLE_NAME + "("
				+ DatabaseConstant.TopChannelsTrace.Field.CHANNELID + " TEXT PRIMARY KEY,"
				+ DatabaseConstant.TopChannelsTrace.Field.CHANNELNAME + " TEXT,"
				+ DatabaseConstant.TopChannelsTrace.Field.CHANNELTYPE + " TEXT,"
				+ DatabaseConstant.TopChannelsTrace.Field.ORDER + " INTEGER" + ");");
	}

    /**
     * 世界杯口袋看球功能新增数据库表（v5.4.1）
     * @param db
     */
    private void createTable_worldCupTrace(SQLiteDatabase db) {

        db.execSQL("CREATE TABLE " + DatabaseConstant.WorldCupTrace.TABLE_NAME + "("
                + "_id INTEGER PRIMARY KEY AUTOINCREMENT," + DatabaseConstant.WorldCupTrace.Field.EPISODE_ID
                + " INTEGER," + DatabaseConstant.WorldCupTrace.Field.ALBUM_ID + " INTEGER,"
                + DatabaseConstant.WorldCupTrace.Field.CID + " INTEGER,"
                + DatabaseConstant.WorldCupTrace.Field.ICON + " TEXT,"
                + DatabaseConstant.WorldCupTrace.Field.EPISODE_ICON + " TEXT,"
                + DatabaseConstant.WorldCupTrace.Field.TYPE + " INTEGER,"
                + DatabaseConstant.WorldCupTrace.Field.ORDER + " INTEGER,"
                + DatabaseConstant.WorldCupTrace.Field.EPISODE_TITLE + " TEXT,"
                + DatabaseConstant.WorldCupTrace.Field.ALBUM_TITLE + " TEXT,"
                + DatabaseConstant.WorldCupTrace.Field.TOTAL_SIZE + " INTEGER,"
                + DatabaseConstant.WorldCupTrace.Field.FINISH + " INTEGER, "
                + DatabaseConstant.WorldCupTrace.Field.TIMESTAMP + " INTEGER,"
                + DatabaseConstant.WorldCupTrace.Field.LENGTH + " INTEGER, "
                + DatabaseConstant.WorldCupTrace.Field.FILE_PATH + " TEXT,"
                + DatabaseConstant.WorldCupTrace.Field.ISHD + " INTEGER,"
                + DatabaseConstant.WorldCupTrace.Field.B_TIME + " INTEGER DEFAULT 0,"
                + DatabaseConstant.WorldCupTrace.Field.E_TIME + " INTEGER DEFAULT 0" + ");");
    }

	private void alterChannelListTable(SQLiteDatabase db) {
		String sql_1 = "CREATE TABLE temp as select _id," + DatabaseConstant.ChannelListTrace.Field.CHANNELID + ","
				+ DatabaseConstant.ChannelListTrace.Field.NUMERICKEYS + ","
				+ DatabaseConstant.ChannelListTrace.Field.NAME + ","
				+ DatabaseConstant.ChannelListTrace.Field.ENAME + ","
				+ DatabaseConstant.ChannelListTrace.Field.HASSAVE
//				+ DatabaseConstant.ChannelListTrace.ChannelStatus.NORMAL
				+ " from " + DatabaseConstant.ChannelListTrace.TABLE_NAME;

		String sql_2 = "drop table if exists " + DatabaseConstant.ChannelListTrace.TABLE_NAME;
		String sql_3 = "alter table temp rename to " + DatabaseConstant.ChannelListTrace.TABLE_NAME;

		db.execSQL(sql_1);
		db.execSQL(sql_2);
		db.execSQL(sql_3);
	}

	private void alterChannelHisTable(SQLiteDatabase db) {

		String sql_1 = "CREATE TABLE temp2 as select _id," + DatabaseConstant.ChannelHisListTrace.Field.CHANNELID + ","
				+ DatabaseConstant.ChannelHisListTrace.Field.NUMERICKEYS + ","
				+ DatabaseConstant.ChannelHisListTrace.Field.NAME + ","
				+ DatabaseConstant.ChannelHisListTrace.Field.ENAME + ","
				+ DatabaseConstant.ChannelHisListTrace.Field.ISRECORD + ","
				+ DatabaseConstant.ChannelHisListTrace.Field.SYSTEMILLISECOND
//				+ DatabaseConstant.ChannelHisListTrace.ChannelStatus.NORMAL
				+ " from " + DatabaseConstant.ChannelHisListTrace.TABLE_NAME;

		String sql_2 = "drop table if exists " + DatabaseConstant.ChannelHisListTrace.TABLE_NAME;
		String sql_3 = "alter table temp2 rename to " + DatabaseConstant.ChannelHisListTrace.TABLE_NAME;

		db.execSQL(sql_1);
		db.execSQL(sql_2);
		db.execSQL(sql_3);
	}

	/*
	String sql="CREATE TABLE "+DatabaseConstant.ChannelHisListTrace.TABLE_NAME+"("
				+ "_id INTEGER PRIMARY KEY AUTOINCREMENT,"+DatabaseConstant.ChannelHisListTrace.Field.CHANNELID
				+" TEXT,"+DatabaseConstant.ChannelHisListTrace.Field.NUMERICKEYS+" TEXT,"
				+DatabaseConstant.ChannelHisListTrace.Field.NAME+" TEXT,"
				+DatabaseConstant.ChannelHisListTrace.Field.ENAME+" TEXT,"
				+ DatabaseConstant.ChannelListTrace.Field.CHANNEL_TYPE+" TEXT,"
				+ DatabaseConstant.ChannelHisListTrace.Field.ISRECORD+" INTEGER,"
				+ DatabaseConstant.ChannelHisListTrace.Field.SYSTEMILLISECOND+" INTEGER,"
				+ DatabaseConstant.ChannelHisListTrace.Field.CHANNELSTATUS+" TEXT DEFAULT "+DatabaseConstant.ChannelHisListTrace.ChannelStatus.NORMAL+");";
		db.execSQL(sql);
	 */
}
